Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use modulo instead of and operation to validate the proof size #101

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

mininny
Copy link
Collaborator

@mininny mininny commented Dec 10, 2024

Description

The slow implementation loads the _proof length from calldata and checks that this length is a multiple of 60.

However, this check uses a logical AND which may lead to accepting invalid values that are not multiple of 60.

	if and(b32asBEWord(calldataload(shortToU64(uint16(stateContentOffset)+paddedStateSize))), shortToU256(60-1)) != (U256{}) {

Moreover, the check is insufficient. _proof is expected to be a multiple of 60 * 32, however only the fact that it is a multiple of 60 is checked.

The logical AND check should be replaced with a modulo operation to ensure that it is a multiple of 32 * 60.

@mininny mininny requested review from clabby and ImTei December 13, 2024 06:53
@BlocksOnAChain BlocksOnAChain added the Audit finding grouping for our audit findings label Dec 16, 2024
@mininny mininny force-pushed the feature/mininny/audit-4 branch from ad0cc5b to c3b3996 Compare January 6, 2025 09:29
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 61.89%. Comparing base (8ff9318) to head (c3b3996).

Files with missing lines Patch % Lines
rvgo/slow/vm.go 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #101   +/-   ##
=======================================
  Coverage   61.89%   61.89%           
=======================================
  Files          27       27           
  Lines        4091     4091           
=======================================
  Hits         2532     2532           
  Misses       1427     1427           
  Partials      132      132           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@refcell
Copy link
Contributor

refcell commented Jan 6, 2025

Testing would be nice so we can avoid potential regression

@mininny mininny added this pull request to the merge queue Jan 22, 2025
Merged via the queue into master with commit 59b7883 Jan 22, 2025
8 checks passed
@mininny
Copy link
Collaborator Author

mininny commented Jan 22, 2025

Added tests here: #135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Audit finding grouping for our audit findings
Development

Successfully merging this pull request may close these issues.

4 participants